<template>
  <div
    class="singleDiv"
    ref="singleDiv"
  >
    <!-- input内容框 -->
    <div class="singleName">
      <i>19%</i>
      <div>
        <textarea
          wrap="soft"
          rows="1"
          readonly
          style="vertical-align:top;outline:none;"
          v-model="data.Internet"
          v-show="isShowss"
        ></textarea>
        <textarea
          rows="1"
          v-model="data.intranet"
          v-show="isShows"
        ></textarea>
      </div>
    </div>
    <!-- 每一个图片 -->
    <div :class="['infoWarp',isShow==true?'infoBG':'']">
      <img
        :src="src"
        alt=""
        class="singlePic"
        @mouseleave="isShow = false"
      />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      required: true,
      type: Object,
    },
  },
  data() {
    // 这里存放数据
    return {
      // name: "负载均衡服务器LBS-1",
      // id: "testID",
      // Internet: "39.99.165.58",
      // intranet: "172.26.137.195",
      // status:'normal',
      isDisabled: true,
      isShow: false,
      isShows: false,
      isShowss: false,
    };
  },
  // 监听属性 类似于data概念
  computed: {
    left: function () {
      return this.data.x + "px";
    },
    top: function () {
      return this.data.y + "px";
    },
    src: function () {
      let obj = {
        normal: "/static/image/board/board_normal.png",
        error: "/static/image/board/board_error.png",
        warning: "/static/image/board/board_warn.png",
      };
      return obj[this.data.status];
    },
    none: function () {
      // intranet = this.data.intranet;
      // this.data.intranet ? "" : (this.$refs["textarea"].style.display = none);
    },
  },
  mounted() {
    // console.log(this.data);
    this.setUI();
    this.none;
  },
  methods: {
    setUI() {
      this.$refs["singleDiv"].style.setProperty("--left", this.left);
      this.$refs["singleDiv"].style.setProperty("--top", this.top);
      this.data.intranet ? this.isShows = true : this.isShows = false;
      this.data.Internet ? this.isShowss = true : this.isShowss = false;
      // if (this.data.intranet) {
      //   this.isShows = true;
      // }
      // if (this.data.Internet) {
      //   this.isShowss = true;
      // }
    },
  },
};
</script>

<style  lang='less' scoped>
.singleDiv {
  position: absolute;
  left: var(--left);
  top: var(--top);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center;
  font-size: 14px;
  font-weight: 400;
  z-index: 2;
}
// input内容框样式
.singleName {
  width: 152px;
  height: 40px;
  line-height: 40px;
  border-radius: 20px;
  background: #00589a;
  display: flex;
  // justify-content: space-between;
  // flex-direction:column;
  align-items: center;
  color: #f50404;
  i {
    width: 36px;
    height: 36px;
    border-radius: 36px;
    background: #c4f807;
    text-align: center;
  }
  textarea {
    display: flex;
    width: 100px;
    resize: none;
    background: #00589a;
    border: none;
    color: #f50404;
  }
}
.textarea {
  // display: none;
  color: #c4f807;
}
</style>